<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>v-on 实例</title>
	</head>
	<body>
		<div id="app">
			<h2>v-on 实例</h2>
			<hr />
			<p>{{num}}</p>
			<br />
			<button v-on:click="add">add</button>
			<button @click="reduce">reduce</button>
			<br />
			自定义加减数值：<input type="text" v-model="custom" v-on:keydown.enter="onEnter"/>
		</div>
		<script src="../assets/js/vue.min.js"></script>
		<script type="text/javascript">
			var vm = new Vue({
				el:'#app',
				data:{
					message: 'Hello World !',
					num: 0,
					custom: 1
				},
				methods: {
					add: function () {
						//return this.num++;
						//return this.num = this.num + this.custom;//拼接string
						return this.num = this.num + parseInt(this.custom);//转换成整形
					},
					reduce: function () {
						return this.num--;
					},
					onEnter: function () {
						return this.num = this.num + parseInt(this.custom);//转换成整形
					}
				}
			})
		</script>
	</body>
</html>
